home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / ctutor2.zip / STRINGS.C < prev    next >
C/C++ Source or Header  |  1987-07-04  |  654b  |  27 lines

  1.                                          /* Chapter 7 - Program 2 */
  2. main()
  3. {
  4. char name1[12],name2[12],mixed[25];
  5. char title[20];
  6.  
  7.    strcpy(name1,"Rosalinda");
  8.    strcpy(name2,"Zeke");
  9.    strcpy(title,"This is the title.");
  10.  
  11.    printf("     %s\n\n",title);
  12.    printf("Name 1 is %s\n",name1);
  13.    printf("Name 2 is %s\n",name2);
  14.  
  15.    if(strcmp(name1,name2)>0)  /* returns 1 if name1 > name2 */
  16.       strcpy(mixed,name1);
  17.    else
  18.       strcpy(mixed,name2);
  19.  
  20.    printf("The biggest name alpabetically is %s\n",mixed);
  21.  
  22.    strcpy(mixed,name1);
  23.    strcat(mixed,"  ");
  24.    strcat(mixed,name2);
  25.    printf("Both names are %s\n",mixed);
  26. }
  27.